package com.ybfenpan.controller.member.ti;

import com.ybfenpan.controller.core.BaseController;
import com.ybfenpan.model.Member;
import com.ybfenpan.model.log.LogMoneyTi;
import com.ybfenpan.service.log.LogMoneyTiService;
import com.ybfenpan.taglib.pagetag.Pagination;
import com.ybfenpan.utils.ContextUtil;
import com.ybfenpan.utils.MapUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


@Controller
 
public class MoneyTiController extends BaseController {

	
	@Resource
	private LogMoneyTiService logMoneyTiService;
	
	@RequestMapping("member/ti/logTiList.shtml")
	public String list(HttpServletRequest request) throws Exception{
		
		//代理商信息
		Member member = ContextUtil.getMember();
		HashMap formMap = getParameterMap(request);
		formMap.put("where", "a.memberId = "+member.getId());
        formMap.put("pagination.orderBy"," a.id desc");  //排列
        Pagination page = logMoneyTiService.queryForPageList("logMoneyTiForPage",formMap);
        request.setAttribute(Pagination.pageBeanName, page);
		return "member/ti/logTiList";
	}
	
	 @RequestMapping("member/ti/logTiShow.shtml")
	    public String moneyTiListShow(HttpServletRequest request) throws Exception{
	        Map formMap = getParameterMap(request);
	        int id = MapUtil.getIntValue(formMap, "id");
	        if(0 < id){
	        	LogMoneyTi logMoneyTi = logMoneyTiService.getByKey(id);
	           
	        	if(logMoneyTi!=null){
	        		Member member = ContextUtil.getMember();
		        	if(member.getId()==logMoneyTi.getMemberId()){
		        		request.setAttribute("logTi",logMoneyTi);
		        	}
	        	}
	        }
	        return "member/ti/logTiShow";
	       
	    }
	
}
